{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 线性判别分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 线性判别分析就是将样例投影到一条直线上，使得同类的样例投影点尽可能小，不同类投影点尽可能远离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os  \n",
    "import sys  \n",
    "import numpy as np  \n",
    "import operator  \n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "group1 = np.random.random((8,2))*5+20\n",
    "group2 = np.random.random((8,2))*5+2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "X1 = group1\n",
    "y1 = np.ones((8,1))\n",
    "X0 = group2\n",
    "y0 = np.zeros((8,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x114137f28>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAADipJREFUeJzt3V+InfWdx/HPJyQXG5UQmyEEceYgLHuz7kY4eFMpLmlL\nFbrqjSBTsVAYL4ro1VacC+3FgHRrt70SRpRm4axQ0G5btizYILjC4nImZE00F8KSCQ0xGQ1EJb1o\nzXcvzjPMZDwn5+9znjPf5/2C4Zz5nefM+ebHwye/83ue5/c4IgQA2P32VF0AAGAyCHQASIJAB4Ak\nCHQASIJAB4AkCHQASIJAB4AkCHQASKJvoNu+0/bbtj+0/YHtp4v2F2xfsH2q+Hmw/HIBAL2435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efyXpZ0l6Sjki5KeqnacqbL\n9q2S3pD0TER8tv21Ou4bXfqjtP2DQB9BRFwoHi9L+rWke6utaCZcKuYMN+cOL1dcT2Ui4lJEfBkR\n1yW9ohrtH7b3qRNerYh4s2iu7b7RrT/K3D8I9CHZvqU4wCHbt0j6tqQzN39XLfxW0hPF8yck/abC\nWiq1GV6FR1ST/cO2Jb0q6WxE/GzbS7XcN3r1R5n7B2e5DMn2XeqMyiVpr6R/i4iVCkuaOtuvS7pf\nnZXjLkl6XtK/S/qVpHl1VtR8NCLSHyzs0Rf3q/N1OiSdk/TktjnktGzfJ+m/JJ2WdL1ofk6deeM6\n7hu9+uMxlbR/EOgAkARTLgCQBIEOAEkQ6ACQBIEOAEkQ6ACQBIEOAEkQ6ACQBIEOAEn8P4MAUrty\njmIAAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x114060160>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X1[:,0],X1[:,1],c='r')\n",
    "plt.scatter(X0[:,0],X0[:,1],c='g')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "mean1=np.array([np.mean(X1[:,0]),np.mean(X1[:,1])])\n",
    "mean0=np.array([np.mean(X0[:,0]),np.mean(X0[:,1])])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 根据周志华西瓜书的61页进行求解"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numpy import mat\n",
    "m1=np.shape(X1)[0]\n",
    "sw=np.zeros(shape=(2,2))\n",
    "for i in range(m1):  \n",
    "    xsmean=mat(X1[i,:]-mean1)  \n",
    "    sw+=xsmean.transpose()*xsmean\n",
    "m0=np.shape(X0)[0]  \n",
    "for i in range(m0):  \n",
    "    xsmean=mat(X0[i,:]-mean0)  \n",
    "    sw+=xsmean.transpose()*xsmean\n",
    "w=(mean0-mean1)*(mat(sw).I)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[-0.5934389 , -0.57983378]])"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1148fac50>]"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFEhJREFUeJzt3X2MHHd9x/HP9x7s5ELq2vjpHHJ3kDh+SM4C1bgQAthx\nHowdZKhaROpWoSAdSLQQqZVIcFXSShb0CUUqpdQtUVN0JEWF1oFzcGIXSghJyJmmPtsRiZP4HMfn\npziYBDexb/fbP3bWt3fevd27nd3Znd/7JaHbnV3vzLDKe/d+85s5c3cBANKvJekNAADUB8EHgEAQ\nfAAIBMEHgEAQfAAIBMEHgEAQfAAIBMEHgEAQfAAIRFvSG1Bo7ty53tPTk/RmAEBT2b1790l3n1fu\neQ0V/J6eHg0ODia9GQDQVMxsuJLnMaQDAIEg+AAQCIIPAIEg+AAQCIIPAIEg+ACaS3+/1NMjtbTk\nfvb3J71FTaOhpmUCwKT6+6W+PunMmdz94eHcfUnatCm57WoSfMMH0Dw2bx6Lfd6ZM7nlKIvgA2ge\nhw5NbTnGIfgAmkdX19SWJ6VBjzMQfADNY8sWqaNj/LKOjtzyeqgk5PnjDMPDkvvYcYYGiD7BB9A8\nNm2Stm6Vursls9zPrVvrc8C20pBP5ThDnX8TMHev6QqmYuXKlc7F0wA0pJ6eXOQn6u6WDh4cu9/S\nkvtAmMhMymbH7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Ppfa71tVo/c6FcEHAJSXhiEdAEAFCD4ABILgA0AgCD4A\nBILgA0AgCD4ABILgA0AgCD4ABOL/AUbbqB4NN3cqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x113bda198>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X1[:,0],X1[:,1],c='r')\n",
    "plt.scatter(X0[:,0],X0[:,1],c='g')\n",
    "x=np.arange(0,25,0.1)\n",
    "y=np.array((-w[0,0]*x)/w[0,1])\n",
    "plt.plot(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
